import { configureStore } from '@reduxjs/toolkit'
import userSlice from './user/user.slice'
import { combineReducers } from '@reduxjs/toolkit'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
  key: 'root',
  storage,
  blacklist: [] // 白名单
}
const rootReducer = combineReducers({
  user: userSlice
})

const persistedRedurcer = persistReducer(persistConfig, rootReducer)

const store = configureStore({
  reducer: persistedRedurcer,
  middleware: getDefaultMiddleware =>
    getDefaultMiddleware({
      serializableCheck: false
    })
})
export default store
const persistor = persistStore(store)
export { persistor }
